<% layout('/layout/default.html', {title: '个人中心', libs: ['validate']}){ %>
<% 
	var defaultSmallUrl = @DictUtils.getDictValue('默认头像','default_headphoto_small','images/userinfo.jpg');
 %>
<style type="text/css">
	.profile-user-img{width:150px;height:150px;}
</style>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-sitemap"></i>个人信息
			</div>
		</div>
		<#form:form id="inputForm" model="${user}" class="form-horizontal" action="${ctx}/sys/user/info" method="post">
			<div class="box-body">
				<#form:hidden path="id"/>
				<div class="row">
					<div class="box box-main">
						<div class="box-body box-profile">
							<img id="avatarImg" class="profile-user-img img-responsive img-circle" src="${user.photo}" onError="this.src='${ctxStatic}/${defaultSmallUrl}';this.onError=null;"/>
							<h3 class="profile-username text-center">${user.name}</h3>
							<input id="imageBase64" name="imageBase64" type="hidden" value="" class="" />
							<script>
							$("#avatarImg").click(function(){
								
								js.layer.open({
									type: 2,
									maxmin: true,
									shadeClose: true,
									title: '图片裁剪',
									area: [(js.layer.$(js.layer.window).width() - 150) + 'px',
									       (js.layer.$(js.layer.window).height() - 100) + 'px'],
									content: '${ctx}/sys/user/headphoto',
									contentFormData: {
										circle: 'true',
										/* imageSrc: $("#avatarImg").attr('src'), */
										imageDefaultSrc: '${ctxStatic}/${defaultSmallUrl}'
									},
									btn: ['<i class="fa fa-check"></i> 确定',
										'<i class="fa fa-eraser"></i> 清除',
										'<i class="fa fa-close"></i> 关闭'],
									btn1: function(index, layero){
										var win = js.layer.iframeWindow(index);
										win.$("#btnGetImageBase64").click();
										$("#avatarImg").attr("src", win.imageBase64);
										$("#imageBase64").val(win.imageBase64).change();
										try { 
											$('#imageBase64').valid();
										 }catch(e){
											 js.layer.close(index);
										}
										 js.layer.close(index);
									},
									btn2: function(index, layero){
										$("#avatarImg").attr("src","${ctxStatic}/${defaultSmallUrl}");
							            $("#imageBase64").val("EMPTY").change();
									}
								});
							});
							</script>								
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="归属公司">
								 归属公司: </label>
							<div class="col-sm-8">
								<div class="form-control" readonly="readonly">
									${user.company.name}
								</div>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="归属部门">
								 归属部门: </label>
							<div class="col-sm-8">
								<div class="form-control" readonly="readonly">
									${user.office.name}
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="用户类型">
								用户类型:
							</label>
							<div class="col-sm-8">
								<div class="form-control" readonly="readonly">
									${@DictUtils.getDictLabel(user.userType, 'sys_user_type', '无')}
								</div>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="用户角色">
								用户角色:
							</label>
							<div class="col-sm-8">
								<div class="form-control" readonly="readonly">
									${user.roleNames}
								</div>
							</div>
						</div>
					</div>
				</div>
				
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="电话">
								电话:
							</label>
							<div class="col-sm-8">
								<#form:input path="phone" maxlength="50" class="form-control" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="手机">
								手机:
							</label>
							<div class="col-sm-8">
								<#form:input path="mobile" class="form-control" maxlength="50" />
							</div>
						</div>
					</div>
				</div>
				
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="邮箱">
								邮箱:
							</label>
							<div class="col-sm-8">
								<#form:input path="email" maxlength="50" class="form-control email"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="上次登录">
								备注:
							</label>
							<div class="col-sm-8">
								<#form:textarea path="remarks" rows="3" cols="32"  class="form-control"></#form:textarea>
							</div>
						</div>
					</div>
				</div>
				
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="上次登录">
								上次登录IP:
							</label>
							<div class="col-sm-8">
								<div class="form-control" readonly="readonly">
									${user.oldLoginIp}
								</div>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="上次登录时间">
								上次登录时间:
							</label>
							<div class="col-sm-8">
								<div class="form-control" readonly="readonly">
									${user.oldLoginDate,dateFormat="yyyy-MM-dd HH:mm:ss"}
								</div>
							</div>
						</div>
					</div>
				</div>
				
			</div>
			<div class="box-footer">
				<div class="row ">
					<div class="text-center col-sm-12">
					<% if (hasPermi('sys:user:edit')){ %>
						<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>
					<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="window.parent.closeCurrentTabPage();"><i class="fa fa-reply-all"></i> 关 闭</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.loading('正在提交，请稍等...');
		form.submit();
	}
});
</script>

<script type="text/javascript">
$(document).ready(function(){
	var msg = "${message}";
	if(msg != null && msg != "") {
		js.showMessage(msg);
	}
});
</script>
